<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %><%--
  Created by IntelliJ IDEA.
  User: XiangLang15078435014
  Date: 2021/11/3
  Time: 16:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>jsp_day01语法</title>
  </head>
  <body>
    <%--
    1.声明： <％!  ...   ％>
    2.脚本java程序片段：<％  ...  ％>
    3.表达式：<％=  ...  ％>
    --%>

      <%--1.声明类属性--%>
      <%!
        private String name;
        private static Map<String, Object> map;

        Map<Integer, String> map1 =new HashMap<Integer,String>();
      %>

      <%--2.声明类方法--%>
      <%!
        public int sum() {
          return 12;
        }
      %>
      <%--3.声明静态代码块--%>
      <%!
        static {
          map = new HashMap<String, Object>();
          map.put("key1", "value1");
        }


      %>

      <%--表达式输出--%>
      <%=sum()%>

      <br>
      <%
        out.write(String.valueOf(map.get("key1"))+"<br>");

        map1.put(1,"你好Kevin老师");
        map1.put(2,"好嘞！");
        out.println(map1);

        //或者这样声明
        Map<String,String> hashMap = new HashMap<>();
      %>


  </body>
</html>
